import { defHttp } from "/@/utils/http/axios";
import { TeachingStudyModel } from "/@/api/model/practicalModel";
import { PageParams, PageResult, PageWithId } from "/@/api/model/pageModel";

enum Api {
  GetTeachingStudyPage = "/teachingStudy/page",
  SaveTeachingStudy = "/teachingStudy/save",
  UpdateTeachingStudy = "/teachingStudy/update",
  RemoveTeachingStudy = "/teachingStudy/remove",
  SetTeachingStudyRemark = "/teachingStudy/setRemark",
}

export const getTeachingStudyPageApi = (params: PageParams) =>
  defHttp.get<PageResult<TeachingStudyModel>>({ url: Api.GetTeachingStudyPage, params });

export const getTeachingStudyPageByIdApi = (params: PageWithId) =>
  defHttp.get<PageResult<TeachingStudyModel>>({
    url: `${Api.GetTeachingStudyPage}/${params.userId}`,
    params,
  });

export const saveTeachingStudyApi = (params: TeachingStudyModel) =>
  defHttp.post<void>({ url: Api.SaveTeachingStudy, params });

export const updateTeachingStudyApi = (params: TeachingStudyModel) =>
  defHttp.put<void>({ url: Api.UpdateTeachingStudy, params });

export const removeTeachingStudyApi = (studyId: number) =>
  defHttp.delete<void>({ url: `${Api.RemoveTeachingStudy}/${studyId}` });

export const setTeachingStudyRemarkApi = (userId: number, studyId: number, content: string) =>
  defHttp.put<void>({
    url: `${Api.SetTeachingStudyRemark}/${userId}/${studyId}`,
    params: { content },
  });
